<?php

namespace app\api\controller\supplier;

use app\api\base\RestfulBase;
use app\modules\supplier\logic\GoodsApplyLogic;

Class GoodsApply extends RestfulBase
{

    protected $logic;

    protected function _initialize()
    {

        $this->logic = new GoodsApplyLogic();

    }

    /**
     * 供应商申请
     * @return json
     */
    public function create()
    {
        if ($this->request->isPost()){
            $data['apply_title'] = $this->getParams('apply_title', '', 'trim,strip_tags');
            $data['supplier_id'] = $this->_account['supplier_id'];
            $data['supplier_user_id'] = $this->_account['supplier_user_id'];

            $data['apply_type'] = $this->getParams('apply_type','','trim,strip_tags');
            $data['apply_intro'] = $this->getParams('apply_intro','','trim,strip_tags');
            $data['apply_time'] = time();
            // $data[''] =$this->getParams('','','trim,strip_tags');

            $result = $this->logic->add($data);
            if ($result) {
                return $this->apiSuccess();
            } else {
                return $this->apiError($this->logic->getError());
            }
        }else{
            return $this->apiError('无效请求');
        }

    }

}

